
import { engine } from "../../engine/engine";
import { CtrlModeListener } from "./GameInputListeners";
import GameInputMgr from "./GameInputMgr";


export default class BaseInputMgr implements CtrlModeListener {
    protected platName: string;
    protected _active: boolean = false;

    onChangeMode(mode: string): void {
        if (mode != this.platName) {
            this._active = false;
        } else {
            this._active = true;
        }
    }

    getActive(): boolean {
        return this._active;
    }


    update(deltaTime: number) {

    }

    init(actionSetNames?: string[], digitalNames?: string[], analogNames?: string[]) {

    }

    clear() {

    }

    onKeyBoardPress(keyCode: number) {
        GameInputMgr.instance().onKeyBoardPress(this.platName, keyCode, null)
    }

    onKeyBoardRelease(keyCode: number) {
        GameInputMgr.instance().onKeyBoardRelease(this.platName, keyCode, null)
    }

    addKeyCode(KEY_CODE: any) {
        GameInputMgr.instance().converter.addKeyCode(this.platName, KEY_CODE)
    }

    addCtrlModeListener() {
        GameInputMgr.instance().addCtrlModeListener(this)
    }

    protected changeType() {
        if (engine.isPaused()) {
            engine.eventShow()
        }
        GameInputMgr.instance().changeType(this.platName)
    }

    onRockerEvent(keyCode: number, x: number, y: number): void {
        GameInputMgr.instance().onRockerEvent(this.platName, keyCode, x, y)
    }

}